<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="CRM.PMF" %>
<%@ page import="CRM.Company" %>
<%@ page import="java.util.List" %>

<%
String name = "";
String website = "";
String owner = "";
String officePhone = "";
String fax = "";
String otherPhone = "";
String email = "";

if( request.getParameter("key") != null )
{
    // Get company datas
    PersistenceManager pm = PMF.get().getPersistenceManager();
    String query = "SELECT FROM " + Company.class.getName() + " WHERE key == " + request.getParameter("key") + " range 0,1";
    List<Company> companies = (List<Company>) pm.newQuery(query).execute();
    Company company = companies.get(0);

    name = company.getName();
    website = company.getWebsite();
    owner = company.getOwner();
    officePhone = company.getOfficePhone();
    fax = company.getFax();
    otherPhone = company.getOtherPhone();
    email = company.getEmail();
}
%>
<%@include file="header.jsp" %>
<form method="post" action="">
    <table>
	<tr>
	    <th colspan="2">Şirket Ekle</th>
	</tr>
	<tr>
	    <th>Adı</th>
	    <td><input type="text" name="name" value="<% request.getParameter("name"); %>" /></td>
	</tr>
	<tr>
	    <th>Web Site</th>
	    <td><input type="text" name="website" value="<% request.getParameter("website"); %>" /></td>
	</tr>
	<tr>
	    <th>Sahibi</th>
	    <td><input type="text" name="owner" value="<% request.getParameter("owner"); %>" /></td>
	</tr>
	<tr>
	    <th>Ofis Telefonu</th>
	    <td><input type="text" name="officePhone" value="<% request.getParameter("officePhone"); %>" /></td>
	</tr>
	<tr>
	    <th>Faks</th>
	    <td><input type="text" name="fax" value="<% request.getParameter("fax"); %>" /></td>
	</tr>
	<tr>
	    <th>Diğer Telefon</th>
	    <td><input type="text" name="otherPhone" value="<% request.getParameter("otherPhone"); %>" /></td>
	</tr>
	<tr>
	    <th>E-Posta</th>
	    <td><input type="text" name="email" value="<% request.getParameter("email"); %>" /></td>
	</tr>
	<tr>
	    <th colspan="2">
		<input type="submit" name="submit" value="Gönder" />
	    </th>
	</tr>
    </table>
</form>
<%@include file="footer.jsp" %>